package com.calm.editor.entity;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Transient;

import com.google.gson.annotations.Expose;

@Entity
@Table(name="XHTML_PAGE")
public class Page {
	@Id
	@Column(name = "ID")
	@GeneratedValue(strategy = GenerationType.TABLE,generator="XHTML_PAGE_ID")
	@TableGenerator(name = "XHTML_PAGE_ID", pkColumnValue = "XHTML_PAGE_ID" , table = "ID_SEQUENCE", pkColumnName = "ID_KEY", valueColumnName = "VALUE", allocationSize = 1)
	private Integer id;
	
	@ManyToOne
	@JoinColumn(name="PROJECT_ID")
	private Project project;
	
	@Column(name = "ELEMENT_ID")
	private String elementId;
	
	@Column(name = "TAG_NAME")
	private String tagName;
	
	@Column(name = "DELETE_CLASS")
	private String deleteClass;
	
	@Column(name = "NAMESPACE")
	private String namespace;
	
	@OneToMany(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY, mappedBy = "page")
	private List<Resource> resources;
	@Transient
	private List<Meta> metas;
	@Column(name = "TITLE")
	private String title;
	
	@OneToMany(cascade=CascadeType.REMOVE)
	@JoinColumn(name = "PAGE_ID")
	@Expose(serialize = false)
	private List<NodeElement> children;
	
	@OneToMany(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
	@JoinColumn(name = "PAGE_ID")
	private List<Namespace> namespaces;
	
	
	public List<Resource> getResources() {
		return resources;
	}

	public void setResources(List<Resource> resources) {
		this.resources = resources;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public List<Meta> getMetas() {
		return metas;
	}

	public void setMetas(List<Meta> metas) {
		this.metas = metas;
	}

	public List<NodeElement> getChildren() {
		return children;
	}

	public void setChildren(List<NodeElement> children) {
		this.children = children;
	}
	
	public List<Namespace> getNamespaces() {
		return namespaces;
	}

	public void setNamespaces(List<Namespace> namespaces) {
		this.namespaces = namespaces;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Project getProject() {
		return project;
	}

	public void setProject(Project project) {
		this.project = project;
	}

	public String getElementId() {
		return elementId;
	}

	public void setElementId(String elementId) {
		this.elementId = elementId;
	}

	public String getTagName() {
		return tagName;
	}

	public void setTagName(String tagName) {
		this.tagName = tagName;
	}

	public String getDeleteClass() {
		return deleteClass;
	}

	public void setDeleteClass(String deleteClass) {
		this.deleteClass = deleteClass;
	}

	public String getNamespace() {
		return namespace;
	}

	public void setNamespace(String namespace) {
		this.namespace = namespace;
	}
	
}
